package com.dq.domain.record;

import com.dq.vo.baseVo.VO;
import com.dq.domain.base.BaseEntity;
import com.dq.domain.sys.section.SysSection;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.utils.TimeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;

/**
 * @Author luchangtong
 * @Date 2019/11/20 15:21
 */
@Entity
@Data
@ApiModel("基本工资设置记录")
public class BasePaySetRecord extends BaseEntity implements VO.ToVO {
    @ApiModelProperty("门店")
    @ManyToOne
    protected SysSection org;
    @ApiModelProperty("员工")
    @ManyToOne
    protected SysUser sysUser;
    @ApiModelProperty("金额")
    protected BigDecimal payPrice;
    @ApiModelProperty("工资编号")
    protected String basePayNo;

    @Data
    @ApiModel(value = "基本工资设置视图")
    public static class Vo implements VO {
        public Long id;
        @ApiModelProperty("基本工资")
        protected BigDecimal payPrice;
        protected Long orgId;
        protected String orgName;
        protected Long staffUserId;
        protected String staffUserNo;
        protected String userRealName;
        protected String basePayNo;
        @ApiModelProperty(value = "创建时间")
        private String createTime;
        @ApiModelProperty(value = "修改时间")
        private String lastModifyTime;
        @ApiModelProperty(value = "创建者id")
        private Long createUserId;
        @ApiModelProperty(value = "创建者name")
        private String createUserName;
        @ApiModelProperty(value = "修改者id")
        private Long updateUserId;
        @ApiModelProperty(value = "修改者name")
        private String updateUserName;
    }

    @Override
    public VO toVO(boolean isRecursion) {
        Vo vo = new Vo();
        vo.id = this.id;
        vo.payPrice = this.payPrice;
        vo.orgId = this.getOrg().getId();
        vo.orgName =this.getOrg().getSimpleName();
        vo.staffUserId = this.sysUser.getId();
        vo.staffUserNo = this.sysUser.getCardNo();
        vo.userRealName = this.sysUser.getUserRealcName();
        vo.basePayNo = this.basePayNo;
        vo.createTime = TimeUtil.longToString(this.createTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.lastModifyTime = TimeUtil.longToString(this.lastModifyTime, TimeUtil.YYYY_MM_DD_HH_MM_SS);
        vo.createUserId = this.createUser == null ? null : this.createUser.getId();
        vo.createUserName = this.createUser == null ? null : this.createUser.getUsername();
        vo.updateUserId = this.updateUser == null ? null : this.updateUser.getId();
        vo.updateUserName = this.updateUser == null ? null : this.updateUser.getUsername();
        return vo;
    }
}
